package com.topvision.myviewtest.recycler.douyin;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.topvision.myviewtest.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @author lucy
 * @date 2018-06-08 14:23
 * @description //TODO
 */

public class DouYinActivity extends AppCompatActivity {

    @BindView(R.id.recyclerview)
    RecyclerView mRecyclerview;
    private Unbinder mBind;
    private DouYinAdapter mDouYinAdapter;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_douyin);
        mBind = ButterKnife.bind(this);
        init();
    }

    private void init() {
        mRecyclerview.setLayoutManager(new DouYinLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        mDouYinAdapter = new DouYinAdapter(R.layout.item_douyin, getData());
        mRecyclerview.setAdapter(mDouYinAdapter);
    }

    private List<String> getData() {
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            list.add(String.valueOf(i + 1));
        }
        return list;
    }

    @Override
    protected void onDestroy() {
        if (mBind != null) {
            mBind.unbind();
        }
        super.onDestroy();
    }
}
